

<%@ page import="com.consorzioimpresa.resuite.domain.Immobile"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="layout" content="springSecurityUI" />
<g:javascript library="prototype" />
<g:javascript library='jquery' plugin='jquery' />
<g:set var="entityName"
	value="${message(code: 'immobile.label', default: 'Immobile')}" />
<title><g:message code="default.create.label"
		args="[entityName]" /></title>
		
		<g:javascript>

function updatePreview(id) {
		var prev = document.getElementById('preview')
		prev.src="/site/viewImage/"+id.responseText
	}
</g:javascript>
</head>
<body>
	<div class="nav">
		<%--            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>--%>
		<span class="menuButton"><g:link class="list" action="list">
				Lista Immobili
			</g:link></span>
	</div>
	<div class="body">
		<h1>
			Crea Immobile 
		</h1>
		<g:if test="${flash.message}">
			<div class="message">
				${flash.message}
			</div>
		</g:if>
		<g:hasErrors bean="${immobileInstance}">
			<div class="errors">
				<g:renderErrors bean="${immobileInstance}" as="list" />
			</div>
		</g:hasErrors>
		<g:form action="save">
			<div class="dialog">
				<table>
					<tbody>
						
						<th width="40%">
						</th>

						<tr class="prop">
							<td valign="top" class="name"><label for="nome"><g:message
										code="immobile.CAP.label" default="Nome" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'Nome', 'errors')}">
								<g:textField name="nome" value="${immobileInstance?.nome}" />
							</td>
						</tr>

						<tr class="prop">
							<td valign="top" class="name"><label for="descrizione"><g:message
										code="immobile.agente.label" default="Descrizione" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'descrizione', 'errors')}">
								<g:textField name="descrizione"
									value="${immobileInstance?.descrizione}" />

							</td>
						</tr>
						<tr class="prop">
							<td valign="top" class="name"><label for="tipologia"><g:message
										code="immobile.tipologia.label" default="Tipologia" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'tipologia', 'errors')}">
								<g:select name="tipologia.id"
									from="${com.consorzioimpresa.resuite.domain.TipologiaImmobile.list()}"
									optionKey="id" value="${immobileInstance?.tipologia?.id}"
									optionValue="nome" />
							</td>
						</tr>
						<tr class="prop">
							<td valign="top" class="name"><label for="zona"><g:message
										code="immobile.zona.label" default="Zona" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'zona', 'errors')}">
								<g:textField name="zona" value="${immobileInstance?.zona}" />
							</td>
						</tr>

						<tr class="prop">
							<td valign="top" class="name"><label for="CAP"><g:message
										code="immobile.CAP.label" default="CAP" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'CAP', 'errors')}">
								<g:textField name="CAP" value="${immobileInstance?.CAP}" />
							</td>
						</tr>
						<tr class="prop">
							<td valign="top" class="name"><label for="indirizzo"><g:message
										code="immobile.zona.label" default="Indirizzo" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'indirizzo', 'errors')}">
								<g:textField name="indirizzo"
									value="${immobileInstance?.indirizzo}" />
							</td>
						</tr>

						<tr class="prop">
							<td valign="top" class="name"><label for="metriQuadri"><g:message
										code="immobile.metriQuadri.label" default="Metri Quadri" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'metriQuadri', 'errors')}">
								<g:textField name="metriQuadri"
									value="${fieldValue(bean: immobileInstance, field: 'metriQuadri')}" />
							</td>
						</tr>
						<tr class="prop">
							<td valign="top" class="name"><label for="prezzo"><g:message
										code="immobile.prezzo.label" default="Prezzo" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'prezzo', 'errors')}">
								<g:textField name="prezzo"
									value="${fieldValue(bean: immobileInstance, field: 'prezzo')}" />
							</td>
						</tr>

						<tr class="prop">
							<td valign="top" class="name"><label for="agente"><g:message
										code="immobile.prezzo.label" default="Agente" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'prezzo', 'errors')}">
								<g:select name="agente.id"
								noSelection="['':'-Scegli l\'agente ']"
									from="${com.consorzioimpresa.resuite.domain.Agente.list()}"
									optionKey="id" value="${immobileInstance?.agente?.id}"
									 />
							</td>
						</tr>



						<tr class="prop">
							<td valign="top" class="name"><label for="anteprima"><g:message
										code="immobile.anteprima.label" default="Anteprima" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'anteprima', 'errors')}">
								<g:select name="anteprima.id" 
									noSelection="['':'-Scegli l\'immaggine dell\'anteprima-']"
									from="${com.consorzioimpresa.resuite.domain.Immagine.list()}"
									optionKey="id" value="${immobileInstance?.anteprima?.id}"
									 onchange="${remoteFunction(
									            controller:'immagine', 
									            action:'ajaxGetID', 
									            params:'\'id=\' + escape(this.value)', 
									            onComplete:'updatePreview(e)')}"
									 />
								 <a href="${createLink(controller:'immagine', action:'create' )}">  -  Crea una nuova Immagine</a>	 
							</td>
						</tr>
						
						<tr class="prop">
							<td valign="top" class="name"><label for="anteprima"><g:message
										code="immobile.anteprima.label" default=" " /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'anteprima', 'errors')}">
							 <img width="70px" height="70px" class="Photo" id="preview"
										src="${createLink(controller:'site', action:'viewImage', id:immobileInstance?.anteprima?.id)}" />		
							</td>
						</tr>


						<tr class="prop">
							<td valign="top" class="name"><label for="numeroVani"><g:message
										code="immobile.numeroVani.label" default="Numero Vani" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'numeroVani', 'errors')}">
								<g:textField name="numeroVani"
									value="${fieldValue(bean: immobileInstance, field: 'numeroVani')}" />
							</td>
						</tr>
						<tr class="prop">
							<td valign="top" class="name"><label for=isPrimoPiano><g:message
										code="contatto.isAnteprima.label"
										default="E' in Primo Piano ?" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'isPrimoPiano', 'errors')}">
								<g:checkBox name="isPrimoPiano"
									value="${immobileInstance?.isPrimoPiano}" />
							</td>
						</tr>
						<tr class="prop">
							<td valign="top" class="name"><label for="isPropostaFutura"><g:message
										code="contatto.isAnteprima.label"
										default="E' una Proposta Futura ?" /></label></td>
							<td valign="top"
								class="value ${hasErrors(bean: immobileInstance, field: 'isPropostaFutura', 'errors')}">
								<g:checkBox name="isPropostaFutura"
									value="${immobileInstance?.isPropostaFutura}" />
							</td>
						</tr>







					</tbody>
				</table>
			</div>
			<div class="buttons">
				<span class="button"><g:submitButton name="create"
						class="save"
						value="Crea" /></span>
			</div>
		</g:form>
	</div>
</body>
</html>
